/******************************************************************
 *
 *    Java Lib For JavaWeb, Powered By Shenzhen WEI YI KE JI .
 *
 *    Copyright (c) 2017-2027 Digital Telemedia Co.,Ltd
 *    http://www.d-telemedia.com/
 *
 *    Package:     com.theyeasy.wykj.activemq.mq.consumer.topic
 *
 *    Filename:    GameTopicReceiver.java
 *
 *    Description: TODO(用一句话描述该文件做什么)
 *
 *    Copyright:   Copyright (c) 2017-2027
 *
 *    Company:     Theyeasy Telemedia Co.,Ltd
 *
 *    @author:     zxt
 *
 *    @version:    1.0.0
 *
 *    Create at:   2017年7月27日 下午3:20:46
 *
 *    Revision:
 *
 *    2017年7月27日 下午3:20:46
 *        - first revision
 *
 *****************************************************************/
package com.theyeasy.dvmini.socket;

import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.theyeasy.dvmini.model.WebSockMsg;

/**
 * @author wykj-4
 * 消费者
 */
@Component
public class DvminiTopicReceiver implements MessageListener {

    private Logger log = LoggerFactory.getLogger(getClass());

    @Override
    public void onMessage(Message msg) {
        try {
            WebSockMsg message = WebSockMsg.fromJson(((TextMessage) msg).getText());
            log.info("接收到消息:message={},to={}", message.getAsk()+","+message.getReply(),
                    message.getFansid());
            QueueMessage.offerMessage(WebSockMsg.fromJson(((TextMessage) msg).getText()));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
